<?php
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;
use doumiaoduo\layer\LayerAsset;
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2">
<div class="docs-main zx-mg">
    <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check"  >
        <thead>
            <tr class="yx-bgd2f6ec">
                <th>学生姓名</th>
                <th>家长姓名</th>
                <th>电话号码</th>
                <th>卡号</th>
                <th>课次</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
    <?php if($details) { ?>
    <?php foreach ($details as $i => $v) { ?>
        <tr>
            <td><?=$v['student_name']?></td>
            <td><?=$v['customer_name']?></td>
            <td><?=$v['tel']?></td>
            <td><?=$v['card_id']?></td>
            <td><?=$v['lesson_num']?></td>
            <td><?php
                switch($v['status']){
                    case 0:
                        echo '未开课';
                        break;
                    case 1:
                        echo '上课中';
                        break;
                    case 2:
                        echo '已结课';
                        break;
                    case 3:
                        echo '转班';
                        break;
                    case 5:
                        echo '续课';
                        break;
                    case 4:
                        echo '退课';
                        break;
                    case 6:
                        echo '已锁定';
                        break;
                }
                ?></td>
            <td>
                <?php if(in_array($v['status'],[0,1]) && $v['is_lock'] == 0) { ?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','transfer',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'name'=>'调班']]);?>
                <?php } else { ?>
                    <button class="yx-btn-disabled" type="button">调课</button>
                <?php }?>
                <?php if($v['studentcheck'] == 0 && $v['is_lock'] == 0 && $v['status'] == 0) { ?>
                   <?php if($v['is_frequency'] == 1) {?>
                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','generatecheck',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'class_id'=>$v['class_manage_id'],'type'=>'single','name'=>'生成签到']]);?>
                   <?php }else {?>
                        <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','generateterm',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'class_id'=>$v['class_manage_id'],'type'=>'single','name'=>'生成签到']]);?>
                   <?php }?>
                <?php } else { ?>
                    <button class="yx-btn-disabled" type="button">生成签到</button>
                <?php } ?>
                <?php if($v['status'] > 0){ ?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','sign',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'name'=>'上课详情']]);?>
                <?php }else{ ?>
                    <button class="yx-btn-disabled" type="button">上课详情</button>
                <?php } ?>
                <?php if($v['is_lock'] == 0 && $v['studentcheck'] ==  0 && $v['status'] == 0) { ?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','lock',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'name'=>'锁定','title'=>'锁定']]);?>
                <?php }elseif($v['is_lock'] == 1 && $v['studentcheck'] ==  0 && $v['status'] == 6) { ?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','lock',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id'],'name'=>'解锁','title'=>'解锁']]);?>
                <?php }else{ ?>
                    <button class="yx-btn-disabled" type="button">锁定</button>
                <?php } ?>
                <?php if($v['is_end'] && $v['status'] ==1) { ?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('newclassmanage','endclass',false,['rel'=>'endclass','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v['id']]]);?>
                <?php }else{ ?>
                    <button class="yx-btn-disabled" type="button">结课</button>
                <?php } ?>
            </td>
        </tr>
    <?php } ?>
   <?php } else { ?>
        <tr>
            <td colspan="6" align="center">暂无学生</td>
        </tr>
   <?php }?>
</table>
   </div>
</div>
<?php
LayerAsset::register($this);
$js=<<<JS
    layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
    $(document).on('click','a[rel="endclass"]',function(){
        var _this = $(this);
        var url = _this.data('url');
        var name = _this.parents('tr').find('td').eq(0).html();
         layer.confirm("确定给学生"+name+"结课么？", {
            title: '结课',
            area: ['440px', '270px'],
            skin: 'layui-confirm-customskin',
            shift:1,
            id:'layer-iframe',
            btn: ['确定','取消'],
            yes: function(index, layero){
                 $.ajax({
                    url:url,
                    type:'get',
                    dataType:'json',
                    _csrf:yii.getCsrfToken(),
                    success:function(data){
                        if(data.status == 1){
                            layer.msg("结课成功！",{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                            location.reload();
                        }
                    }

                });
              layer.close(index);
            }
         });
        return false;
    });

JS;
\Yii::$app->view->registerJs($js);
?>